﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Nxg.Blog.Core.Documents {
    public class BlogComment {
        [Key, DatabaseGenerated (DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        [Required]
        public string Content { get; set; }

        [Required, MaxLength (20)]
        public string NickName { get; set; }

        [Required, EmailAddress]
        public string Email { get; set; }

        [Url]
        public string SiteUrl { get; set; }

        [Required]
        public DateTime CreatedTime { get; set; }

        [Required]
        public int PostId { get; set; }

        public string IPAddress { get; set; }

        [NotMapped]
        public string Avatar {
            get {
                var imgUrl = string.Format ("https://secure.gravatar.com/avatar/{0}.png?s={1}&d={2}&r=g", "", 60, "mm");
                return imgUrl;
            }
        }
    }
}